//
//  CommentHeadView.m
//  ProjectsOne
//
//  Created by iOS开发 on 2018/7/10.
//  Copyright © 2018年 iOS开发. All rights reserved.
//

#import "CommentHeadView.h"

@implementation CommentHeadView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, WIDTH - 20, 45)];
    bgView.backgroundColor = [UIColor whiteColor];
    [self addSubview:bgView];

    UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:bgView.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(3, 3)];
    CAShapeLayer * maskLayer = [[CAShapeLayer alloc]init];
    maskLayer.frame = bgView.bounds;
    maskLayer.path = maskPath.CGPath;
    bgView.layer.mask = maskLayer;
    
    UILabel *moreLabel = [[UILabel alloc] init];
    moreLabel.font = [UIFont systemFontOfSize:16];
    moreLabel.textColor = [UIColor colorWithHexString:@"333333"];
    moreLabel.text = @"用户评论";
    [self addSubview:moreLabel];
    
    [moreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.left.mas_equalTo(bgView).with.offset(7);
    }];
    
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = [UIColor colorWithHexString:@"ffa631"];
    [self addSubview:line];
    
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(2);
        make.left.mas_equalTo(bgView);
        make.centerY.mas_equalTo(bgView);
        make.height.mas_equalTo(15);
    }];
    
    _moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:_moreButton];
    [_moreButton setTitle:@"查看更多 >" forState:UIControlStateNormal];
    _moreButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [_moreButton setTitleColor:[UIColor colorWithHexString:@"999999"] forState:UIControlStateNormal];
    
    [_moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self).with.offset(-15);
        make.centerY.mas_equalTo(bgView);
    }];
    
    UIView *bottomLine = [[UIView alloc] init];
    bottomLine.backgroundColor = [UIColor colorWithHexString:@"#dddddd"];
    [self addSubview:bottomLine];
   
    [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(.5f);
        make.bottom.left.right.mas_equalTo(bgView);
    }];
    
    
}

@end
